package com.itheima.service.impl;

import com.itheima.mapper.ReportMapper;
import com.itheima.pojo.JobOption;
import com.itheima.pojo.StudentCountDate;
import com.itheima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private ReportMapper reportMapper;
    @Override
    public JobOption getEmpJobDate() {
        List<Map<String,Object>> list = reportMapper.getEmpJobDate();
        List<Object> jobList = list.stream().map(date -> date.get("pos")).collect(Collectors.toList());
        List<Object> dateList = list.stream().map(date -> date.get("num")).collect(Collectors.toList());
        return new JobOption(jobList,dateList);
    }

    @Override
    public StudentCountDate getStudentDate() {
        List<Map<String,Object>> list = reportMapper.getStudentDate();
        List<Object> clazzList = list.stream().map(map -> map.get("clazzName")).collect(Collectors.toList());
        List<Object> dateList = list.stream().map(map -> map.get("num")).collect(Collectors.toList());
        return new StudentCountDate(clazzList,dateList);
    }

    @Override
    public List<Map> getStudentDegreeDate() {
        List<Map> list = reportMapper.getStudentDegree();
        return list;
    }

    @Override
    public List<Map> getEmpGenderData() {
        return reportMapper.countEmpGenderData();
    }
}
